home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
wb
/
czesc_3
/
newdeftool
/
source
/
ndt101.s
< prev
next >
Wrap
Text File
|
1992-04-15
|
93KB
|
2,185 lines
OPT l-,c+,d-,a+,o+
;****************************************************************************
;* *
;* NewDefaultTool V1.01 by Kjell Cederfeldt 91-Aug-03 *
;* *
;* Copyright (C) by Kjell Cederfeldt 1992. All rights reserved. /\ *
;* / / *
;* Change Default tool in a project icon. /\ / / *
;* \ \/ / *
;* Written in DevPac assembler on an A3000. \/ / *
;* \/ *
;* Kjell Cederfeldt Phone +46 (0)31 - 306334 home *
;* Hammarkulletorget 39 +46 (0)31 - 139316 office *
;* S-442 37 ANGERED SWEDEN +46 (0)31 - 306310 support BBS *
;* *
;* UseNet ...{uunet|pyramid|rutgers}!cbmvax!cbmehq!cbmswe!datac!kjell *
;* *
;****************************************************************************
include 2:Offset/Offsets.i
include 2:Base.i
incdir "2:20_include/" ;where to look
include exec/ports.i
include intuition/intuition.i
include libraries/dos_lib.i ;and DOS
include libraries/dos.i
include dos/dosextens.i
include libraries/asl.i
include workbench/startup.i
include workbench/workbench.i
MEMF_TYPE = $10001
MEMF_PUBLIC = $0000001
MTYPE_CHIP = $0000002 ; Memory type bits
MEMF_CLEAR = $0010000
MEMF_ANY_CLEAR = $10000
; move.w #0,$dff180 ;TEST! FLASH THE SCREEN!! NOTE! DEBUG ONLY.
DEBUG = 0 ;(0=Nej ingen debug (ingen appiocn i CLI-mode) 1=Ja Debug (Appicon i CLI-mode))
*******************************************************************************
****** ********************************************
****** START OF MAIN PROGRAM ********************************************
****** ********************************************
*******************************************************************************
INIT_AMIGA
Start:
lea DosName,a1
bsr OpenLib ;Open Doslibrary
move.l d0,DosBase ;Save Dosbase
beq Cleanup ;Error on open. Exit
lea IconName,a1 ;get icon text string
bsr OpenLib ;Open Iconlibrary
move.l d0,IconBase ;Save Iconbase
beq Cleanup ;Error in open. Exit
lea IntName(pc),a1 ;get 'intuition.library'
bsr OpenLib ;Open intuitionlibrary
move.l d0,IntBase ;svae intuitionbase
beq Cleanup ;Error in open Exit.
lea WBName(pc),a1 ;get 'workbench.library'
bsr OpenLib ;Open Workbenchlibrary
move.l d0,WBBase ;svae Workbenchbase
beq Cleanup ;Error in open Exit.
bsr PointTOCLI ;get our cli
bsr ScreenMSG ;print text to CLI-window
* Alloc memory for selected icons witch will be changed.
move.l #1024,d0 ;request 1024 bytes of mem
bsr AllocMem ;AllocMem
move.l d0,FileMem ;save pointer to our mem
* Alloc memory for fileinfoblock we get from examine (configuration file)
MoreAlloc
move.l #260,d0 ;request 260 bytes of mem
bsr AllocMem ;AllocMem
move.l d0,FileInfoMem ;save pointer to our mem
* Alloc memory for newdeftool string
;note 255 in loop MutchPattern:
move.l #256,d0 ;request 256 bytes of mem
bsr AllocMem ;AllocMem
move.l d0,NewDefTool ;save pointer to our mem
* Alloc memory for copydeftool string
move.l #515,d0 ;request 515 bytes of mem
bsr AllocMem ;AllocMem
move.l d0,CopyDefTool ;save pointer to our mem
bsr OpenCfgFile ;Open and read configfile.
cmp.l #0,RetCode1 ;RetCode=NULL error in Cfg-file.
beq Cleanup
CheckCLIArgs ;Args from CLI!
IFEQ DEBUG
cmp.l #1,(WBTRUE).l ;Check if start from WB or CLI
beq.s NOTStartFromCLI ;no start from CLI
;Check args from CLI!
move.w #0,APPICONTRUE ;Forget AppIcons flag (Set to untrue)
NOTStartFromCLI
ENDC
ArgListloop
move.l ArgList(pc),a1 ;get adress to arguments
cmp.b #0,(a1) ;have we some arg?
beq.s CheckAppArgs ;no!
move.w #0,APPICONTRUE ;Forget AppIcons flag (Set to untrue)
bsr GetCLIArg ;Get Arguments from CLI
tst.l d0
beq EXIT ;no more entrys.
bsr HandleFile
cmp.w #1,CLIMORE
beq.s ArgListloop
bra EXIT
CheckAppArgs ;Args from AppIcon/Window
cmp.w #1,APPICONTRUE ;Check if AppIcon in cfg-file!
bne CheckAslArgs ;nix no AppIcon
*****************************************************************
;Check in we already have our messageport in system, if so, we have
;a sleeping copy of this program as a task already.
;Send message to sleeping task to wakeup. (Show the window).
; Already in use? We will not run another copy of this program.
move.l (ExecBase).w,a6 ;Execbase
lea PortName(pc),a1 ;get our portname.
jsr _FindPort(a6) ;try to find our port
tst.l d0 ;found it?
beq.s NoMsgPort ;No! countinue.
move.l d0,FoundPort ;yes save the pointer to port were the
;message will go.
move.l TaskAdr,a4 ;find our userport were the reply
lea pr_MsgPort(a4),a0 ;will go!
move.l a0,MyPort ;save pointer to the replyport.
moveq.l #86,d0 ;request 86 bytes of mem for AppMessagestructure
bsr AllocMem ;AllocMem
move.l d0,AppMsgStruct ;save pointer to our mem
move.l d0,a1
move.l MyPort,MN_REPLYPORT(a1) ;set replyport
move.w #86,MN_LENGTH(a1)
move.b #NT_MESSAGE,LN_TYPE(a1) ;set type of message
move.l #64,am_UserData(a1)
move.l #1,am_ID(a1)
move.l FoundPort,a0 ;get port to send message.
move.l (ExecBase).w,a6 ;Execbase
jsr _PutMsg(a6) ;send the message to the sleeping task
move.l MyPort(pc),a0
jsr _WaitPort(a6) ;hämta meddelande
move.l MyPort(pc),a0
jsr _GetMsg(a6) ;hämta meddelande
move.l AppMsgStruct(pc),a1 ;get pointer to alloced mem.
moveq.l #86,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
move.l #0,MyPort ;Clear label so Cleanuprutin no try to remove som ports
bra.s Cleanup ;and den terminate!
NoMsgPort
*****************************************************************
bsr GetAPPArg
tst.l d0
beq.s CheckAslArgs ;no more entrys.
bra.s EXIT
CheckAslArgs ;Args from Asl-filerequester
bsr GetASLArg
bsr HandleFile
; bra.s EXIT
EXIT ;here the main program ends
****************************************************************************
****************************************************************************
********* *********************************
********* CLEANUP AND EXIT PROGRAM *********************************
********* *********************************
****************************************************************************
****************************************************************************
Cleanup
cmp.w #1,APPICONTRUE
bne.s Cleanup1
bsr RemAppIcon ;remove AppIcon
Cleanup1
move.l MyPort(pc),d0 ;get our port
beq.s Cleanup2 ;created ?
bsr DeletePort ;yes! then remove it.
Cleanup2
move.l NewDefTool(pc),a1 ;get pointer to alloced mem.
move.l #256,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
move.l CopyDefTool(pc),a1 ;get pointer to alloced mem.
move.l #515,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
move.l ConfigMem(pc),a1 ;get pointer to alloced mem.
move.l FileLen,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
move.l EntryMem(pc),a1 ;get pointer to alloced mem.
move.l ENTRYS,d0 ;equal to alloced bytes of mem!
mulu #31,d0
bsr FreeMem ;FreeMem
move.l FileInfoMem(pc),a1 ;get pointer to alloced mem.
move.l #260,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
move.l FileMem(pc),a1 ;get pointer to alloced mem.
move.l #1024,d0 ;equal to alloced bytes of mem!
bsr FreeMem ;FreeMem
Cleanup3
move.l (ExecBase).w,a6
move.l IconBase(pc),a1 ;get iconbase
cmp.l #0,a1 ;have we any iconbase
beq.s Cleanup4 ;no!
jsr _CloseLibrary(a6) ;yes close Doslibrary
Cleanup4
move.l (ExecBase).w,a6
move.l WBBase(pc),a1 ;get Workbench base
cmp.l #0,a1 ;have we any iconbase
beq.s Cleanup5 ;no!
jsr _CloseLibrary(a6) ;yes close Doslibrary
Cleanup5
move.l (ExecBase).w,a6 ;
move.l AslBase(pc),a1 ;get ASlbase
cmp.l #0,a1 ;have we any ASlbase?
beq.s Cleanup6 ;no!
jsr _CloseLibrary(a6) ;yes close ASLlibrary
Cleanup6
move.l (ExecBase).w,a6 ;
move.l IntBase(pc),a1 ;get Intbase
cmp.l #0,a1 ;have we any Intbase?
beq.s Cleanup7 ;no!
jsr _CloseLibrary(a6) ;yes close Intlibrary
Cleanup7
move.l (ExecBase).w,a6
move.l DosBase(pc),a1 ;get Dosbase
cmp.l #0,a1 ;have we any dosbase?
beq.s Cleanup8 ;no!
jsr _CloseLibrary(a6) ;yes close Doslibrary:
Cleanup8
EXIT_AMIGA
CFGName1: dc.b 's:'
CFGName2: dc.b 'NewDefTool.cfg',0
even
*****************************************************************************
*****************************************************************************
*****************************************************************************
*****************************************************************************
***** ******** ***********
***** END OF MAIN PROGRAM ******** SUBRUTINS BEGINS HERE ***********
***** ******** ***********
*****************************************************************************
*****************************************************************************
*****************************************************************************
*****************************************************************************
************************************************************************
***** **************************************************
***** HandleFile **************************************************
***** **************************************************
************************************************************************
; This routine handles file (include path) in alloced FileMem (The
; selected file). IF the file is a directory then all files in the
; directory will be scanned and changed if match with config-file.
HandleFile:
bsr CheckFileDir ;test if argument is a file or
cmp.l #0,RetCode1 ;a direktory.
bne.s HandleFileCount
bra.s EndHandleFile
HandleFileCount
cmp.l #0,DirEntryType
blt.s SingleFILE ;the path was a file
bsr ScanDir ;read in all entrys in directory
DirEntryLoop
bsr FindNextFile ;find nextfile in dir
tst.l d0
beq.s Ending ;no more entrys.
SingleFILE
bsr FixINFO ;mask .info if exists in filename
bsr GetDefTool ;get default tool from icon.
tst.l d0 ;get default from project-icon?
beq.s EndOfFinds ;No! Don't do any thing.
bsr FindNewDefToolFF ;find replace tool via namelist
cmp.w #1,MatchOK ;have we a match? if no try toollist
beq.s EndOfFinds
bsr FindNewDefTool ;find replace tool and change if found!
EndOfFinds
bsr FreeDiskObj ;free the poor icon (free diskobject)
NoProjectChange
cmp.l #0,DirEntryType ;are we in an direcory?
bgt.s DirEntryLoop ;yes try next icon
Ending
bsr UnLockFileDir ;unlock the lock on file or dir
cmp.l #0,DirEntryType ;are we in an directory?
blt.s EndHandleFile ;no! end this funktion.
move.l DosBase(pc),a6 ;get DOS base
move.l OldLock,d1 ;get the filelock
jsr _CurrentDir(a6) ;get back to old CD!
EndHandleFile
rts
*****************************************************************************
***** **************************************************
***** REPLY MESSAGE **************************************************
***** **************************************************
*****************************************************************************
ReplyMSG
move.l (ExecBase).w,a6 ;basadress till EXEC i a6
move.l NewMessage(pc),d0 ;hämta meddeladet
beq.s EndReplyMSG ;inget meddelande att besvara.
move.l d0,a1
jsr _ReplyMsg(a6) ;besvara meddelandet
move.l #0,NewMessage ;nolla gammalt meddelande
EndReplyMSG
rts
*****************************************************************************
***** ***********************************************
***** OPEN LIBRARY ***********************************************
***** ***********************************************
*****************************************************************************
OpenLib
moveq #37,d0
move.l (ExecBase).w,a6
jsr _OpenLibrary(a6)
rts
*****************************************************************************
***** ***********************************************
***** ALLOC/FREE MEMORY ***********************************************
***** ***********************************************
*****************************************************************************
AllocMem ;INPUTS -> d0=MemSize
move.l (ExecBase).w,a6
move.l #MEMF_ANY_CLEAR,d1 ;any type of mem.
jsr _AllocMem(a6) ;AllocMem
tst.l d0
beq.s AllocError ;no errors, count.
rts
; OUTPUTS <- d0 location of memoryblock.
AllocError
bsr NoMemMSG ;print text to CLI-window
bra Cleanup ;no memory. Exit
;**** Freememory ****
; INPUTS -> a1=pointer to memory block
; -> d0=MemSize in bytes
FreeMem
move.l (ExecBase).w,a6 ;Exec base
cmp.l #0,a1
beq.s NoAlloc
jsr _FreeMem(a6) ;FreeMem
NoAlloc rts
**************************************************************************
********** ************************************
********** GET ARGUMENTS FROM CLI ************************************
********** ************************************
**************************************************************************
GetCLIArg
moveq.l #0,d0
move.l ArgList(pc),a1 ;get pointer to cli arguments
GetCLIArgStart
cmp.b #' ',(a1) ;start of argument?
bne.s ReadCliArg
cmp.b #0,(a1) ;NULL found?start of argument?
beq CliArgError
addq.l #1,a1
move.l a1,(ArgList).l
bra.s GetCLIArg
ReadCliArg
cmp.b #'-',(a1) ;have we some switch?
beq ArgSwitch ;yes read them!
cmp.b #'?',(a1) ;have we some switch?
beq CliHelp ;yes read them!
ReadCLIArg
move.l FileMem(pc),a0 ;get pointer to alloced mem
move.l ArgList(pc),a1 ;get pointer to cli arguments
move.w #0,CLIMORE
CLIReadPathLoop
move.b (a1),(a0) ;Move from arglist to filemem
beq.s ReadCliEnd ;end of arguments?
cmp.b #34,(a1)
beq.s CliFnutt
cmp.b #' ',(a1) ;end of this argument
beq.s ReadCliTempEnd
addq.l #1,a0
addq.l #1,a1
bra.s CLIReadPathLoop
CliFnutt
addq.l #1,a1
CliFnuttLoop
move.b (a1),(a0) ;Move from arglist to filemem
beq CliArgError2
cmp.b #34,(a1)
beq.s EndCliFnutt
addq.l #1,a0
addq.l #1,a1
bra.s CliFnuttLoop
EndCliFnutt
addq.l #1,a1
cmp.b #0,(a1)
beq.s ReadCliEnd
cmp.b #' ',(a1)
bne.s CliArgError2
ReadCliTempEnd ;end of filename not arguments
addq.l #1,a1
cmp.b #' ',(a1)
beq.s ReadCliTempEnd
move.l a1,(ArgList).l
cmp.b #0,(a1)
beq.s ReadCliEnd
move.w #1,CLIMORE
ReadCliEnd ;end of filename and arguments
move.b #0,(a0) ;always null terminate string
;**************************
move.l DosBase(pc),a6
move.l FileMem(pc),d1 ;get pointer to alloced mem
moveq.l #ACCESS_READ,d2 ;lock for read
jsr _Lock(a6)
tst.l d0
beq.s CliArgError2
move.l d0,d6
move.l d6,d1
move.l FileMem(pc),d2 ;get pointer to alloced mem
move.l #1024,d3
jsr _NameFromLock(a6)
move.l d6,d1
jsr _UnLock(a6)
moveq.l #1,d0 ;set funktion successful.
ArgErrFile
rts
ArgSwitch
addq.l #1,a1
cmp.b #'h',(a1)
beq.s CliHelp ;yes
cmp.b #'?',(a1)
beq.s CliHelp ;yes
; bra.s CliArgError
CliArgError
bsr ErrorMSG ;yes
moveq.l #0,d0 ;set funktion unsuccessful.
rts
CliArgError2
bsr Error2MSG ;yes
moveq.l #0,d0 ;set funktion unsuccessful.
rts
CliHelp
bsr HelpMSG ;yes
moveq.l #0,d0 ;set funktion unsuccessful.
rts
**************************************************************************
********** *********************************
********** APPICON/WINDOW ARGUMENTS *********************************
********** *********************************
**************************************************************************
GetAPPArg
bsr CreatePort ;Yes create port
tst.l d0
beq Cleanup ;Error Cleanup
bsr AddAppIcon ;Create AppIcon!
cmp.l #0,d0
beq AppIconNotFound
move.l MyPort(pc),a0
moveq #1,d2
moveq #0,d1
move.b MP_SIGBIT(a0),d1
lsl.l d1,d2
move.l d2,MysigBit
AppLoop:
move.l (ExecBase).w,a6 ;basadress till EXEC i a6
move.l MysigBit,d0
jsr _Wait(a6)
Mess1
move.l (ExecBase).w,a6 Execbase
move.l MyPort(pc),a0
jsr _GetMsg(a6) ;hämta meddelande
move.l d0,NewMessage
beq.s AppLoop ;ingen händelse
HandleAppMsg
move.l NewMessage,a1
move.l am_ID(a1),d1 ;ID# från AppWindow
cmp.l #1,d1
bne AppError
move.l am_UserData(a1),d1 ;UserData från AppWindow
cmp.l #64,d1
bne AppError
move.l NewMessage,a1
move.l am_NumArgs(a1),d1 ;nuber of argument from AppIcon
cmp.l #0,d1 ;0=Dubbleclick on AppIcon
beq AppUserWindow
move.l d1,d5
subq.l #1,d5
move.l NewMessage,a1
move.l am_ArgList(a1),a4 ;Antal argument från AppIcon
WBArgLoop
move.l DosBase(pc),a6 ;get DOS base
move.l wa_Lock(a4),d1 ;Get lock
move.l FileMem,d2
move.l #1024,d3 ;request 1024 bytes of mem
jsr _NameFromLock(a6)
beq.s EndAppMsg
move.l wa_Name(a4),a1 ;Antal argument från AppIcon
cmp.b #0,(a1)
beq.s EndAddAppName
move.l FileMem(pc),a3
FindAppPath
cmp.b #0,(a3)+
bne.s FindAppPath
EndFindAppPath
subq.l #2,a3
cmp.b #':',(a3)+
beq.s AddAppName
move.b #'/',(a3)+
AddAppName
move.b (a1)+,(a3)+
bne.s AddAppName
EndAddAppName
move.l a4,-(sp)
move.l d5,-(sp)
bsr HandleFile
move.l EntryMem(pc),a1 ;get pointer to alloced mem.
move.l ENTRYS,d0 ;equal to alloced bytes of mem!
mulu #31,d0
bsr FreeMem ;FreeMem
move.l #0,EntryMem ;get pointer to alloced mem.
move.l (sp)+,d5
move.l (sp)+,a4
addq.l #8,a4
dbra d5,WBArgLoop
EndAppMsg
bsr ReplyMSG ;reply message
bra AppLoop
AppError
bsr ReplyMSG ;reply message
bsr DisplayFlash
bra AppLoop
AppQuit
bsr ReplyMSG ;reply message
moveq.l #1,d0
EndGetAPPArg
rts
AppIconNotFound
bsr AppErrMSG
moveq.l #1,d0
rts
AppUserWindow
bsr ReplyMSG ;rep|y message
lea EASYStruct2,a1
bsr Request
cmp #1,d0
beq.s FuncHide
bra.s FuncQuit
FuncHide
bsr.s FuncReply ;rep|y message
bra AppLoop
FuncQuit
bsr.s FuncReply ;rep|y message
bra.s AppQuit
FuncReply
move.l (ExecBase).w,a6 ;Execbase
move.l MyPort(pc),a0
jsr _GetMsg(a6) ;hämta meddelande
move.l d0,NewMessage
beq.s EndFuncReply ;ingen händelse
bsr ReplyMSG ;rep|y message
bra.s FuncReply
EndFuncReply rts
**************************************************************************
********** ************************************
********** OPEN FILEREQUESTERS ************************************
********** ************************************
**************************************************************************
GetASLArg
* ASL FileRequester in OS 2.0
OpenASL lea AslName(pc),a1
bsr OpenLib ;Open Asllibrary
move.l d0,AslBase
beq Cleanup ;Error on open.
move.l AslBase(pc),a6
moveq.l #ASL_FileRequest,d0
lea AslTags(pc),a1
jsr _AllocAslRequest(a6)
move.l d0,FileReq ;save handle
beq Cleanup ;no handle error, exit
move.l FileReq(pc),a0
lea AslTags(pc),a1
jsr _AslRequest(a6)
tst.l d0
beq Cleanup ;CANCEL
move.l FileReq(pc),a0
move.l FileReq(pc),a0 ;get pointer to asl strukture.
bsr BuildPathASL
move.l AslBase(pc),a6
move.l FileReq(pc),a0
jsr _FreeFileRequest(a6)
ENDAsl
rts
AslTags dc.l ASL_Hail,titletxt
dc.l ASL_MinHeight,200
dc.l ASL_Height,200
dc.l ASL_Width,302
dc.l ASL_MaxHeight,400
dc.l TAG_DONE
titletxt dc.b 'Select icon to retool',0
even
*****************************************************************************
******* ***************************
******* CHECK SELECTED PATH DIR OR FILE ? ***************************
******* ***************************
*****************************************************************************
CheckFileDir
move.l FileMem,d1 ;get pointer filename
move.l DosBase(pc),a6 ;get DOS base
moveq.l #SHARED_LOCK,d2 ;read only
jsr _Lock(a6) ;lock the file
move.l d0,MyFileLock ;remember the lock
tst.l d0 ;ok?
bne.s CheckDubbelCheck ;no
move.l #-1,DirEntryType ;>0 = Dir, <0 = File
move.l #1,RetCode1
rts
CheckDubbelCheck
move.l #0,RetCode1
move.l d0,d1
move.l FileInfoMem(pc),d2 ;pointer to FileInfoBlock
jsr _Examine(a6)
tst.l d0 ;ok?
beq.s UnLockFileDir ;no
move.l #1,RetCode1
move.l FileInfoMem(pc),a0 ;address to FileInfoBlock
addq.l #fib_DirEntryType,a0 ;offset to filelen
move.l (a0),DirEntryType ;>0 = Dir, <0 = File
cmp.l #0,(a0)
blt.s UnLockFileDir ;bransh if file (unlock if file)
move.l MyFileLock,d1 ;get the filelock
jsr _CurrentDir(a6)
move.l d0,OldLock
CheckFileDirEnd rts
******************************************************************************
UnLockFileDir
cmp.l #0,MyFileLock ;have we a lock?
beq.s EndUnLockFileDir ;no! Do not try to unlock.
move.l DosBase(pc),a6
move.l MyFileLock,d1 ;get filelock
jsr _UnLock(a6) ;release it
move.l #0,MyFileLock ;delete filelock-pointer
EndUnLockFileDir rts
******************************************************************************
**** **** ***
**** SCAN/READ DIRECTORY **** ALLOC NEEDED MEMORY FOR ENTRYS IN DIR ***
**** **** ***
******************************************************************************
ScanDir
move.l ENTRYS,d0 ;get actual numbers of entrys.
mulu #31,d0 ;mult numbers of character in array
bsr AllocMem ;AllocMem
move.l d0,EntryMem ;save pointer to our mem
move.l EntryMem(pc),a5 ;get pointer arraydata
moveq.l #0,d5
FindNextFile2
addq.l #1,d5 ;add readed entrys
cmp.l ENTRYS,d5 ;compere with alloced number of entrys
bcc.s AllocMoreEntrys ;we need to alloc more entrys.
move.l MyFileLock,d1 ;get the filelock
move.l FileInfoMem(pc),d2 ;pointer to FileInfoBlock
move.l DosBase(pc),a6 ;get DOS base
FindNextEntry2
jsr _ExNext(a6) ;get next entry
tst.l d0
beq.s FindNextFileEnd2 ;no more entrys
move.l FileInfoMem(pc),a0 ;address to FileInfoBlock
addq.l #fib_DirEntryType,a0 ;offset to filetype
cmp.l #0,(a0) ;dir or file?
bgt.s FindNextFile2 ;dir, get next entry
InfoFilter
move.l FileInfoMem(pc),a0 ;address to FileInfoBlock
addq.l #fib_FileName,a0 ;offset to filename
cmp.b #0,(a0)
beq.s FindNextFile2 ;emptyname (no name) get next.
FindFilterSTR
cmp.b #0,(a0)+ ;find NULL-terminate (End of string)
bne.s FindFilterSTR
subq.l #6,a0
lea InfoStr,a1
moveq #0,d0
FilterStrLoop
cmp.b (a0)+,(a1)+ ;look after .info in filename
bne.s FindNextFile2
addq #1,d0
cmp.l #5,d0
bne.s FilterStrLoop ;not found OK! Keep going
move.l FileInfoMem(pc),a0 ;address to FileInfoBlock
addq.l #fib_FileName,a0 ;offset to filename
move.l a5,a1 ;get start offset in array
MoveNameLoop2
cmp.b #0,(a0)
beq.s MoveNameEnd2
move.b (a0)+,(a1)+
bra.s MoveNameLoop2
MoveNameEnd2
move.b #0,(a1) ;dont forget to terminate
add.l #31,a5 ;next row in array
move.b #0,(a5)
bra.s FindNextFile2
FindNextFileEnd2
move.l EntryMem(pc),a5 ;get pointer arraydata
rts
AllocMoreEntrys
bsr UnLockFileDir ;release filelock from MyFileLock
move.l DosBase(pc),a6 ;get DOS base
move.l OldLock,d1 ;get the filelock
jsr _CurrentDir(a6) ;back too startdir
move.l (ExecBase).w,a6 ;Exec base
move.l EntryMem(pc),a1 ;get pointer to alloced mem.
cmp.l #0,a1
beq.s AllocMoreCont
move.l ENTRYS,d0 ;equal to alloced bytes of mem!
mulu #31,d0
jsr _FreeMem(a6) ;FreeMem
move.l #0,EntryMem ;NULL pointer to alloced mem.
AllocMoreCont
bsr CheckFileDir ;test if argument is a file or
; cmp.l #0,RetCode1 ;no error checks needs because
; beq Ending ;we already know it alright (just for locks and so)
move.l ENTRYS,d0 ;get actual numbers of entrys.
add.l d0,d0 ;bubble entrys alloc memory
move.l d0,ENTRYS ;save numbers of entrys.
bra ScanDir ;start to read again.
ENTRYS dc.l 512 ; 512 entrys.
*******************************************************************************
******** ************************************
******** FIND NEXT FILE FROM FILE MEM ************************************
******** ************************************
*******************************************************************************
FindNextFile
moveq.l #0,d0 ;null alert funktion
move.l a5,a0 ;get actual arraydata pointer.
move.l FileMem,a1 ;get pointer filenamemem
cmp.b #0,(a0)
beq.s FindNextFileEnd
MoveNameLoop
cmp.b #0,(a0)
beq.s MoveNameEnd
move.b (a0)+,(a1)+
bra.s MoveNameLoop
MoveNameEnd
move.b #0,(a1) ;dont forget to terminate
moveq.l #1,d0 ;alert funktion is well
add.l #31,a5 ;add to next entry in array.
FindNextFileEnd
rts
*****************************************************************************
**************** **************************************
**************** WRITE TEXT STRING **************************************
**************** **************************************
*****************************************************************************
NoMemMSG:
lea EasyMEMERRText,a1
move.l a1,EASYText
lea EASYStruct,a1
bsr Request
rts
*************************************************************
CfgErrMSG:
lea EasyCFGERRText,a1
move.l a1,EASYText
lea EASYStruct,a1
bsr Request
move.l #0,RetCode1
rts
AppErrMSG:
lea EasyAPPERRText,a1
move.l a1,EASYText
lea EASYStruct,a1
bsr Request
rts
OpenCfgErrMSG:
lea EasyOpenCFGERRText,a1
move.l a1,EASYText
lea EASYStruct,a1
bsr Request
move.l #0,RetCode1
rts
ScreenMSG:
move.l #SText1,d2 ;point to textstring
move.l #SText1E-SText1,d3 ;string length
bsr TextWrite ;write string
rts
HelpMSG:
move.l #HText1,d2 ;point to textstring
move.l #HText1E-HText1,d3 ;string length
bsr.s TextWrite ;write string
rts
ErrorMSG:
move.l #EText,d2 ;point to textstring
move.l #ETextE-EText,d3 ;string length
bsr.s TextWrite ;write string
rts
Error2MSG:
move.l #E2Text,d2 ;point to textstring
move.l #E2TextE-E2Text,d3 ;string length
bsr.s TextWrite ;write string
rts
FoundMSG:
move.l #FoundStr,d2 ;point to textstring
move.l #EFoundStr-FoundStr,d3 ;string length
bsr.s TextWrite ;write string
rts
ChangeMSG:
move.l #ChangeStr,d2 ;point to textstring
move.l #EChangeStr-ChangeStr,d3 ;string length
bsr.s TextWrite ;write string
rts
WriteDefTool:
move.l Diskobj(pc),a1 ;get diskobj strukture.
move.l do_DefaultTool(a1),a1
moveq #0,d3
DirNLen: cmp.b #0,(a1)+
beq.s WriteDN
addq.l #1,d3
bra.s DirNLen
WriteDN:
move.l Diskobj(pc),a1 ;get diskobj strukture.
move.l do_DefaultTool(a1),a1
move.l a1,d2
bsr.s TextWrite ;skriv strängen
rts
WriteFeed
move.l #Feed,d2 ;pekare till textsträngen
moveq.l #1,d3 ;sträng längd
bsr.s TextWrite ;skriv strängen
rts
*****************************************************************************
TextWrite:
tst.l (WBTRUE).l
bne.s ENDTextWrite
move.l DosBase(pc),a6
move.l CLIpoint(pc),d1
jsr _Write(a6)
ENDTextWrite
rts
******************************************************************************
********** *****************************************
********** BUILD PATH FROM ASL *****************************************
********** *****************************************
******************************************************************************
BuildPathASL
move.l FileMem(pc),a1 ;get pointer to alloced mem.
move.l a0,a3
move.l rf_Dir(a0),a2 ;Path string
cmp.b #0,(a2)
bne.s BLDAslPath
subq #1,a1
bra.s BuildFileASL
BLDAslPath
move.b (a2),(a1)+
cmp.b #0,(a2)+
bne.s BLDAslPath
subq.l #2,a1
cmp.b #':',(a1)
beq.s BuildFileASL
addq.l #1,a1
move.b #'/',(a1)
BuildFileASL
addq.l #1,a1
move.l a3,a0
move.l rf_File(a0),a2 ;file string
cmp.b #0,(a2)
beq.s EndPathASL
BLDAslFile
move.b (a2),(a1)+
cmp.b #0,(a2)+
bne.s BLDAslFile
EndPathASL
rts
******************************************************************************
************* ******************
************* FIXINFO / MASK .INFO STRING IN FILENAME ******************
************* ******************
******************************************************************************
FixINFO
move.l FileMem(pc),a1 ;get pointer filename
cmp.b #0,(a1)
beq Cleanup
FindInfoSTR
cmp.b #0,(a1)+ ;find NULL-terminate (End of string)
bne.s FindInfoSTR
subq.l #6,a1
move.l a1,a3
lea InfoStr,a0
moveq #0,d0
InfoStrLoop
cmp.b (a0)+,(a1)+ ;look after .info in filename
bne.s EndInfoStr
addq #1,d0
cmp.l #5,d0
bne.s InfoStrLoop ;not found OK! Keep going
move.b #0,(a3) ;Delete .info in filename.
EndInfoStr
rts
*****************************************************************************
************** ***********************
************** Get DefaultToolstring from Diskobj. ***********************
************** ***********************
*****************************************************************************
GetDefTool:
move.l FileMem(pc),a0 ;get pointer path & filename
move.l IconBase(pc),a6
jsr _GetDiskObject(a6) ;get diskobject
move.l d0,Diskobj ;Save diskobjectet pointer
beq.s GetDefToolEnd ;Error!
moveq.l #0,d0
move.l Diskobj(pc),a1 ;get diskobj strukture.
cmp.b #4,do_Type(a1) ;check if project-icon!
bne.s GetDefToolEnd ;no! End this funktion.
tst.l (WBTRUE).l
bne.s NoDefWrite
bsr FoundMSG ;write foundtext to CLI
bsr WriteDefTool ;write defaulttool to CLI
NoDefWrite
moveq.l #1,d0
GetDefToolEnd
rts
******************************************************************************
****** **** ***************
****** Find New Default Tool **** CHANGE DEFAULT TOOL ***************
****** **** ***************
******************************************************************************
* ;Check first if filename match the configfile
*
*
* ;a0=configfile a1=string olddefaulttool a2=string filename in cfg-file
*
FindNewDefToolFF ;(FF=FromFile)
move.l StartOFFiles(pc),a2 ;get pointer config-memory
move.l CopyDefTool,a3 ;get pointer old default string
move.l NewDefTool,a4 ;get pointer where put new sting
move.w #0,MatchOK ;reset match remember value.
MainFindLoopFF
move.l DosBase(pc),a6
move.l FileMem(pc),d1 ;get pointer path & filename
jsr _FilePart(a6) ;take only filename!
move.l d0,d6
bsr.s MatchPattern
cmp.w #1,MatchOK ;have we a match? if no try next row
beq.s EndFindDefToolFF
FindNewRowFF
cmp.b #0,(a2) ;end of config-file?
beq.s EndFindDefToolFF ;Yes quit.
cmp.l EndOFFiles,a2 ;End of Files (get from INIT)
bcc.s EndFindDefToolFF ;yes, quit.
cmp.b #10,(a2)+ ;end of row?
beq.s MainFindLoopFF ;yes, make new match-check
bra.s FindNewRowFF ;no count.
EndFindDefToolFF
rts
*
* ;a0=configfile a1=string olddefaulttool a2=string newdeftool
*
FindNewDefTool
move.l StartOFTools(pc),a2 ;get pointer config-memory
move.l CopyDefTool,a3 ;get pointer old default string
move.l NewDefTool,a4 ;get pointer where put new sting
move.w #0,MatchOK ;reset match remember value.
MainFindLoop
move.l Diskobj(pc),a1 ;get diskobj strukture.
move.l do_DefaultTool(a1),d6 ;get pointer to old DefTool (matchstring)
bsr.s MatchPattern
cmp.w #1,MatchOK ;have we a match? if no try next row
beq.s EndFindDefTool
FindNewRow
cmp.b #0,(a2) ;end of config-file?
beq.s EndFindDefTool ;Yes quit.
cmp.l EndOFTools,a2 ;End of tools (get from INIT)
bcc.s EndFindDefTool ;yes, quit.
cmp.b #10,(a2)+ ;end of row?
beq.s MainFindLoop ;yes, make new match-check
bra.s FindNewRow ;no count.
EndFindDefTool
rts
************************************************************************
MatchPattern
move.l NewDefTool,a0 ;get source-workbuffer for ParsePattern
move.l CopyDefTool,d2 ;get dest-workbuffer for ParsePattern
move.l #255,d1
SourceMatchLoop
move.b (a2)+,(a0) ;Copy to sourcebuffer from configmem and NULL-terminate
cmp.b #0,(a0) ;if end of configmem=Error
beq.s nomatching
cmp.b #10,(a0) ;if end of-row configmem=Error
beq CFGInitError2 ;error in config file. Quit
cmp.b #' ',(a0) ;(space) end of sourcestring?
beq.s EndSourcematchLoop ;yes!
cmp.b #9,(a0) ;(TAB) end of sourcestring?
beq.s EndSourcematchLoop ;yes!
addq.l #1,a0 ;Add!
dbra d1,SourceMatchLoop
bra CFGInitError2 ;error in config file. Quit
EndSourcematchLoop
move.b #0,(a0) ;NULL-Terminate
subq.l #1,a2 ;back address
move.l a2,Rememb ;remember. we count. from here later.
move.l NewDefTool,d1 ;get NULL-Terminater sourcebuffer
move.l #515,d3 ;Length of bytes in dest-buffer.
move.l DosBase(pc),a6
jsr _ParsePatternNoCase(a6) ;Parse string from Configmem (are there som wildcards)
cmp.l #-1,d0 ;error while parsing (0 and 1 is OK!)
beq.s nomatching
move.l CopyDefTool,d1 ;Get parsed workbuffer as matchbuffer
move.l d6,d2
jsr _MatchPatternNoCase(a6) ;Match parsed string with string from Icon
bne.s FindChangeString ;jump if strings match
nomatching rts
FindChangeString
move.l Rememb,a2 ;first space betwin source/dest string
FindChangeLoop
cmp.b #' ',(a2)
beq.s FindChangeCount2
cmp.b #9,(a2)
beq.s FindChangeCount2
bra.s FindChangeCount
FindChangeCount2
addq.l #1,a2
bra.s FindChangeLoop
FindChangeCount
cmp.b #0,(a2)
beq CFGInitError2 ;error in config file. Quit
ChangeLoop2
move.b (a2),(a4)
cmp.b #10,(a2)
beq.s ChangeStringDone
addq.l #1,a2
addq.l #1,a4
bra.s ChangeLoop2
ChangeStringDone
move.b #0,(a4)
bsr.s PutNewDefTool
move.w #1,MatchOK ;alert an match. No more tryes.
rts
Rememb dc.l 0
**********************************************************************************
PutNewDefTool
move.l Diskobj(pc),a1 ;get diskobj strukture.
move.l NewDefTool,a4 ;get pointer where put new sting
move.l a4,do_DefaultTool(a1) ;get pointer to old DefTool
move.l IconBase(pc),a6
move.l FileMem(pc),a0 ;get pointer path & filename
move.l Diskobj,a1
jsr _PutDiskObject(a6)
bsr ChangeMSG ;write defaulttool to CLI
bsr WriteDefTool ;write defaulttool to CLI
bsr WriteFeed ;write defaulttool to CLI
rts
**********************************************************************************
********** ************************************
********** INIT CONFIGURATION IN MEMORY ************************************
********** ************************************
**********************************************************************************
INITCONFIG
FindUserInterface ;how to request? via AppIcon, AppWindow or filerequest?
; (if no cli-args ?!)
move.l ConfigMem(pc),a0 ;get pointer config-memory
move.l a0,EndOFUIface ;save this if no AppIcon found
UIface lea INTERFACESTRING,a3 ;get pointer to APPICON: string
UItartTLoop
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3 ;A=A?
beq.s UIStartTool2 ;yes check rest of argument
cmp.b #0,(a0)+ ;No! end of config?
bne.s UItartTLoop ;no, check if found foward
bra FindStartTools ;error in configfile
UIStartTool2
addq.l #1,a0
addq.l #1,a3
cmp.b #0,(a0)
beq CFGInitError ;error in configfile
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3
bne.s UIface
cmp.b #':',(a3)
bne.s UIStartTool2
UIEqual
addq.l #1,a0
cmp.b #'=',(a0) ;find = charcter
beq.s UIEqualEnd
cmp.b #' ',(a0) ;only space pleace (if not =)
beq.s UIEqual
bra CFGInitError ;error in configfile
UIEqualEnd
addq.l #1,a0
cmp.b #0,(a0) ;är file slut?
beq CFGInitError ;error in configfile
cmp.b #' ',(a0) ;leta upp början
beq.s UIEqualEnd
move.l a0,StartOFUIface ;här borde iconnamnet (m path)
;i cfg-filen börja.
FindUITxtEnd
addq.l #1,a0
cmp.b #' ',(a0) ;leta upp slutet
beq.s MarkUIFTXTEnd ;markera slutet av filnamn.
cmp.b #10,(a0) ;leta upp slutet
beq.s MarkUIFTXTEnd ;markera slutet av filnamn.
cmp.b #0,(a0) ;leta upp början
beq CFGInitError ;error in config file
bra.s FindUITxtEnd
MarkUIFTXTEnd
move.b #0,(a0) ;NULL terminate the name.
addq.l #1,a0
move.l a0,EndOFUIface ;end of path
move.w #1,APPICONTRUE ;notify AppIcon will be used
;********** Find X: = ??? and Y: ???
move.l EndOFUIface(pc),a0 ;get pointer config-memory
FindAppXPos lea APPX,a3 ;get pointer to X: string
AppXPosLoop1
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3 ;X=X?
beq.s AppXPosLoop2 ;yes check rest of argument
cmp.b #0,(a0)+ ;No! end of config?
bne.s AppXPosLoop1 ;no, check if found foward
bra FindStartTools ;error in configfile
AppXPosLoop2
addq.l #1,a0
addq.l #1,a3
cmp.b #0,(a0)
beq CFGInitError ;error in configfile
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3
bne.s FindAppXPos
cmp.b #':',(a3)
bne.s AppXPosLoop2
AppXEqual
addq.l #1,a0
cmp.b #'=',(a0) ;find = charcter
beq.s AppXEqualEnd
cmp.b #' ',(a0) ;only space pleace (if not =)
beq.s AppXEqual
bra CFGInitError ;error in configfile
AppXEqualEnd
addq.l #1,a0
cmp.b #0,(a0) ;är file slut?
beq CFGInitError ;error in configfile
cmp.b #' ',(a0) ;leta upp början
beq.s AppXEqualEnd
GetXPos
moveq #0,d1
move.l d1,APPICONX
XPosLoop move.b (a0)+,d1 ;läs tecken från arglist
cmp.b #' ',d1 ;slut på tecken?
beq.s EndFindAppXPos ;Ja hopp till loop
cmp.b #10,d1 ;slut på tecken?
beq.s EndFindAppXPos ;Ja hopp till loop
cmp.b #0,d1 ;är arglista slut ?
beq CFGInitError ;error in configfile
move.l APPICONX,d0 ;hämta tidigare tal
move.l d1,d3
moveq #10,d1
bsr Mulu3232 ;Multipl. two longwords
move.l d3,d1
move.l d0,APPICONX ;spara multiplicerat tal
bsr ASCIIHex ;omvandla tecken till tal
add.l d1,APPICONX ;addera och spara talet
bra.s XPosLoop ;hopp till loop
EndFindAppXPos
move.l EndOFUIface(pc),a0 ;get pointer config-memory
FindAppYPos lea APPY,a3 ;get pointer to Y: string
AppYPosLoop1
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3 ;Y=Y?
beq.s AppYPosLoop2 ;yes check rest of argument
cmp.b #0,(a0)+ ;No! end of config?
bne.s AppYPosLoop1 ;no, check if found foward
bra.s FindStartTools ;error in configfile
AppYPosLoop2
addq.l #1,a0
addq.l #1,a3
cmp.b #0,(a0)
beq CFGInitError ;error in configfile
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3
bne.s FindAppYPos
cmp.b #':',(a3)
bne.s AppYPosLoop2
AppYEqual
addq.l #1,a0
cmp.b #'=',(a0) ;find = charcter
beq.s AppYEqualEnd
cmp.b #' ',(a0) ;only space pleace (if not =)
beq.s AppYEqual
bra CFGInitError ;error in configfile
AppYEqualEnd
addq.l #1,a0
cmp.b #0,(a0) ;är file slut?
beq CFGInitError ;error in configfile
cmp.b #' ',(a0) ;leta upp början
beq.s AppYEqualEnd
GetYPos
moveq #0,d1
move.l d1,APPICONY
YPosLoop move.b (a0)+,d1 ;läs tecken från arglist
cmp.b #' ',d1 ;slut på tecken?
beq.s EndFindAppYPos ;Ja hopp till loop
cmp.b #10,d1 ;slut på tecken?
beq.s EndFindAppYPos ;Ja hopp till loop
cmp.b #0,d1 ;är arglista slut ?
beq CFGInitError ;error in configfile
move.l APPICONY,d0 ;hämta tidigare tal
move.l d1,d3
moveq #10,d1
bsr Mulu3232 ;multipl. to longwords
move.l d3,d1
move.l d0,APPICONY ;spara multiplicerat tal
bsr ASCIIHex ;omvandla tecken till tal
add.l d1,APPICONY ;addera och spara talet
bra.s YPosLoop ;hopp till loop
EndFindAppYPos
bra.s FSTools
; ***********
FindStartTools
move.l EndOFUIface(pc),a0 ;get pointer config-memory
FSTools lea TOOLSSTRING,a3 ;get pointer to TOOLS: string
FStartTLoop
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3 ;T=T?
beq.s FStartTool2 ;yes check rest of argument
cmp.b #0,(a0)+ ;No! end of config?
bne.s FStartTLoop ;no, check if found foward
bra CFGInitError ;error in configfile
FStartTool2
addq.l #1,a0
addq.l #1,a3
cmp.b #0,(a0)
beq.s CFGInitError ;error in configfile
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3
bne.s FSTools
cmp.b #10,(a3)
bne.s FStartTool2
addq.l #1,a0
move.l a0,StartOFTools
FindEndTools
move.l StartOFTools(pc),a0 ;get pointer StartTools block
FETools lea FILESTRING,a3 ;get pointer to FILENAME: string
FEndTLoop
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3 ;F=F?
beq.s FEndTool2 ;ja kolla mer
cmp.b #0,(a0)+ ;Nej slut config?
bne.s FEndTLoop ;nej kolla nästa
bra.s CFGInitError ;fel i configfile
;här kankse man kunde Sätta EndOFTools
FEndTool2
move.l a0,a5 ;kom ihåg EnfOFTools
subq #1,a5
FEndTool3 addq.l #1,a0
addq.l #1,a3
cmp.b #0,(a0)
beq.s CFGInitError ;error in configfile
move.b (a0),d0
move.b (a3),d3
cmp.b d0,d3
bne.s FETools
cmp.b #10,(a3)
bne.s FEndTool3
addq.l #1,a0
move.l a5,EndOFTools
move.l a0,StartOFFiles
; OBS **; om TOOLTYPE: skall in så måste detta ändras!
move.l ConfigMem(pc),a0 ;get pointer starttools block
add.l FileLen,a0
move.l a0,EndOFFiles
move.l #1,RetCode1
rts
CFGInitError2
bsr.s FreeDiskObj
bsr CfgErrMSG
bra Cleanup
CFGInitError
bsr CfgErrMSG
move.l #0,RetCode1
rts
INTERFACESTRING dc.b 'APPICON:',10,0
even
APPX dc.b 'X:',10,0
even
APPY dc.b 'Y:',10,0
even
TOOLSSTRING dc.b 'TOOLS:',10,0
even
FILESTRING dc.b 'FILENAME:',10,0
even
TOOLTYPESTRING dc.b 'TOOLTYPE:',10,0
even
******************************************************************************
***** *************************************************
***** FREE DISK OBJECT *************************************************
***** *************************************************
******************************************************************************
FreeDiskObj
move.l IconBase(pc),a6
move.l Diskobj,a0
cmp.l #0,a0
beq.s EndFreeDiskObj
jsr _FreeDiskObject(a6)
EndFreeDiskObj
rts
******************************************************************************
******* ****************************************
******* OPEN CONFIG FILE FROM DISK ****************************************
******* ****************************************
******************************************************************************
OpenCfgFile
move.l #CFGName1,d1 ;get filename
bsr LockFile
cmp.l #0,d0
beq.s Opf2 ;Error in open try next path
move.l #CFGName1,d1 ;get filename
bsr OpenFile
cmp.l #0,d0
beq Cleanup ;can lock but not open=error quit
bra.s EndCfgOpen
Opf2:
lea (CFGName1).l,a0 ;get filename
move.b #'/',1(a0) ;chane path
move.l a0,d1 ;get new path of filename
move.l #CFGName1,d1 ;get filename
bsr.s LockFile
cmp.l #0,d0
beq.s Opf3 ;Error in open try next path
move.l #CFGName1,d1 ;get filename
bsr OpenFile
cmp.l #0,d0
beq Cleanup ;can lock but not open=error quit
bra.s EndCfgOpen
Opf3:
move.l #CFGName2,d1 ;get filename
bsr.s LockFile
cmp.l #0,d0
beq OpenCfgErrMSG
move.l #CFGName2,d1 ;get filename
bsr OpenFile
cmp.l #0,d0
beq Cleanup ;can lock but not open=error quit
EndCfgOpen
move.l (ExecBase).w,a6
move.l FileLen,d0 ;request filelen bytes of mem
move.l #MEMF_ANY_CLEAR,d1 ;any type of mem.
jsr _AllocMem(a6) ;AllocMem
move.l d0,ConfigMem ;save pointer to our mem
bne.s Readcfg
bsr.s CloseCfgFile
bsr.s UnLockFile
bsr NoMemMSG ;print text to CLI-window
bra Cleanup ;no memory. Exit
Readcfg bsr.s ReadCfgFile
bsr.s CloseCfgFile
bsr.s UnLockFile
rts
***************************************************************************************
LockFile
move.l DosBase(pc),a6 ;get DOS base
moveq.l #SHARED_LOCK,d2 ;read only
jsr _Lock(a6) ;lock the file
move.l d0,MyFileLock ;remember the lock
beq.s EndLockFile ;problem to lock!
move.l d0,d1
move.l FileInfoMem(pc),d2 ;pointer to FileInfoBlock mem
jsr _Examine(a6)
tst.l d0 ;ok?
beq Cleanup ;no ??????
move.l FileInfoMem(pc),a0 ;adressen till FileInfoBlock
add.l #fib_Size,a0 ;offset to filelen
move.l (a0),FileLen ;save the length of file in bytes
moveq #1,d0
EndLockFile
rts
******************************************************************************
UnLockFile
move.l DosBase(pc),a6
move.l MyFileLock,d1 ;get filelockpointer.
jsr _UnLock(a6) ;relese lock.
move.l #0,MyFileLock ;clear pointer.
rts
******************************************************************************
OpenFile
move.l #MODE_OLDFILE,d2 ;read only
jsr _Open(a6) ;Open file
move.l d0,CfgFile ;save pointer to file
EndOpenFile
rts
******************************************************************************
CloseCfgFile
move.l DosBase(pc),a6 ;get DOS base
move.l CfgFile,d1 ;get filepointer
jsr _Close(a6) ;Open file
rts
******************************************************************************
ReadCfgFile
move.l DosBase(pc),a6 ;get DOS base
move.l CfgFile,d1 ;get filepointer
move.l ConfigMem(pc),d2 ;adressen till FileInfoBlock
move.l FileLen,d3
jsr _Read(a6) ;Open file
beq Cleanup ;Error in Close ??????
bsr INITCONFIG ;mark Start/end TOOLS & FILES
rts
******************************************************************************
PointTOCLI:
move.l DosBase(pc),a6 ;doslibrary pekare till
tst.l (WBTRUE).l ;koll om Start WB el CLI?
bne.s PointTOWB ;om WB hopp
jsr _Output(a6) ;hämta output pekare till Dos!
move.l d0,CLIpoint ;Spara undan pekaren
PointTOWB:
rts
*****************************************************************************
********* ************************************
********* ADDAPPICON / REMOVEAPPICON ************************************
********* ************************************
*****************************************************************************
AddAppIcon
move.l StartOFUIface,a0
move.l IconBase(pc),a6
jsr _GetDiskObject(a6) ;get diskobject
move.l d0,AppDiskOBJ ;Save diskobjectet pointer
beq.s EndAddAppIcon
move.l AppDiskOBJ(pc),a3 ;Pekare till Diskobjstrukt
move.l APPICONX,do_CurrentX(a3)
move.l APPICONY,do_CurrentY(a3)
move.l WBBase(pc),a6 Hämta workbenchBase
moveq #1,d0 ID#
moveq #64,d1 se i autodoc WB.doc (2.0)
sub.l a2,a2
sub.l a4,a4
move.l MyPort(pc),a1
lea AppIconTxt(pc),a0 ;Pekare till texten
move.l AppDiskOBJ(pc),a3 ;Pekare till Diskobjstrukt
jsr _AddAppIconA(a6) ;lägg till under toolmeny ny Item
move.l d0,AppIconHandle ;Spara AppIcon hanteraren
EndAddAppIcon
rts
AppIconTxt dc.b 'NewDefTool',0
even
;****************************************************************************
RemAppIcon
move.l WBBase(pc),a6 ;Get Workbench-base
move.l AppIconHandle(pc),a0 ;get handler
cmp.l #0,(a0)
beq.s RemAppICont
jsr _RemoveAppIcon(a6) ;Remove AppIcon
RemAppICont
move.l IconBase(pc),a6 ;Free read diskobj (icon)
move.l AppDiskOBJ,a0 ;Free Diskobj get by GetDiskObj()
cmp.l #0,(a0)
beq.s EndRemAppIcon
jsr _FreeDiskObject(a6)
EndRemAppIcon
rts
*****************************************************************************
********* ***************************************
********* CREATEPORT / DELETEPORT ***************************************
********* ***************************************
*****************************************************************************
CreatePort
move.l (ExecBase).w,a6 ;Laddar Execbase
moveq #-1,d0
jsr _AllocSignal(a6)
cmp.b #-1,d0
beq.s Crt_Err
move.l d0,sigbit
moveq #34,d0 längden på messagestrukturen
move.l #MEMF_TYPE,d1 public-mem + clear
jsr _AllocMem(a6) allokera minne
bne.s CreateCount
move.l sigbit(pc),d0
jsr _FreeSignal(a6)
Crt_Err moveq #0,d0
rts
CreateCount
move.l d0,MyPort Spara adressen till minne/MSGstrukturen
move.l d0,a4 samt till a4
move.b #NT_MSGPORT,LN_TYPE(a4) ;sturcture Node
move.b pri(pc),LN_PRI(a4) ;prioriteten
move.l #PortName,LN_NAME(a4) ;adressen till namnet
move.b #PA_SIGNAL,MP_FLAGS(a4)
sub.l a1,a1
jsr _FindTask(a6) hitta vårt task
move.l d0,MP_SIGTASK(a4) spara det
move.l MyPort(pc),a1 adressen till MSGstrukturen
jsr _AddPort(a6) lägg till porten
move.l MyPort(pc),d0
EndCreatePort rts
******************************************************************************
DeletePort
move.l (ExecBase).w,a6 ;Ladda Execbase
move.l MyPort(pc),a4 ;portsturkturen
move.l MyPort(pc),a1
jsr _RemPort(a6) avlägnsa porten
;* OBS Dessa två rader råder det tvivel om Det skiljer sig mellan RKM och
; Amiga System programer's guide.
move.l #-1,MP_SIGTASK(a4) ;Enligt RKM manualen.
move.l #$FF,(a4) Enligt Amiga System prog. guide
move.l #-1,MP_MSGLIST(a4)
moveq #0,d0
move.b MP_SIGBIT(a0),d0
jsr _FreeSignal(a6)
move.l MyPort(pc),a1 adressen till minnet vi allokerade
moveq #34,d0 antal allokerade byte
jsr _FreeMem(a6) frigör minnet.
EndDelPort
rts
****************************************************************************
***** ***************************************
***** BORDERDRAW BORDER TEXT ***************************************
***** ***************************************
****************************************************************************
DisplayFlash: ;*Visar en flash i skärmen a0
move.l IntBase(pc),a6 ;basadressen till intuition i a6
sub.l a0,a0 ;skärmens hanterare i a0
jsr _DisplayBeep(a6) ;Flash
rts
****************************************************************************
***** *********************************
***** EasyRequest on error *********************************
***** *********************************
****************************************************************************
Request ;in a1<== EasyStructure
move.l IntBase(pc),a6
sub.l a0,a0
sub.l a2,a2
sub.l a3,a3
jsr _EasyRequestArgs(a6)
rts
****************************************************************************
***** *********************************
***** ASCII->Hex Convert AscII to Hex *********************************
***** *********************************
****************************************************************************
;ASCII to hex. Converts one character.
;Requires (character ASCII) (d1)
;Returns (converted value) (d1)
ASCIIHex:
sub.b #'A',d1 ;Subtract $41
bcc.s InsertChar ;Branch if A =< d0 =< F.
addq.b #7,d1 ;Else correct d0.
InsertChar:
add.b #10,d1 ;And add 10.
rts ;Ready.
****************************************************************************
***** *********************************
***** MULU3232 *********************************
***** *********************************
****************************************************************************
Mulu3232: ;32*32-bit unsigned multiply
;Operation d0*d1 => d0 , 32*32=>32
;Source operands:
;d0 = ULONG
;d1 = ULONG
;Result:
;d0 = ULONG
;d1 = UBYTE, set if overflow, otherwise cleared
move.l d2,-(sp)
moveq #0,d2
Mulu3232_a:
lsr.l #1,d0
bcc.s Mulu3232_b
add.l d1,d2
bvs.s Mulu3232_Done
Mulu3232_b:
add.l d1,d1
tst.l d0
bne.s Mulu3232_a
Mulu3232_Done:
svs d1
move.l d2,d0
move.l (sp)+,d2
rts
*****************************************************************************
********* **************************************************
********* DATA / Text **************************************************
********* **************************************************
*****************************************************************************
InfoStr: dc.b '.info',0
DosName: dc.b 'dos.library',0
even
IconName: dc.b 'icon.library',0
even
IntName: dc.b 'intuition.library',0
even
AslName: dc.b 'asl.library',0
even
WBName: dc.b 'workbench.library',0
even
PortName: dc.b 'NDT_Port',0
even
SText1: dc.b 10,'
NewDefTool V1.01 © Copyright by Kjell'
dc.b ' Cederfeldt 1992 ',10,10
SText1E: even
HText1:
dc.b ' Programmed in 100% Assembler by Kjell Cederfeldt in'
dc.b ' Jan 1992',10,' This is Public Domain',10,10
dc.b 'Usage: NewDefTool <file|dir> [file|dir]..',10,10
HText1E: even
EText:
dc.b 'Bad arguments, Usage "NewDefTool -?" for help',10,10,10
ETextE: even
E2Text:
dc.b 'Bad arguments or filename',10,10,10
E2TextE: even
FoundStr:
dc.b 10,'Found tool... '
EFoundStr: even
ChangeStr:
dc.b 10,'changed to... '
EChangeStr: even
Txt1: dc.b 'NewDefaultTool V1.01',0
even
EASYStruct dc.l 20 ;Len of structure
dc.l 0
dc.l EasyTitle
EASYText dc.l EasyCFGERRText
dc.l EasyABORT
EndEasyStruct dc.l 0
EasyTitle dc.b 'NewDefTool Error Request',0
even
EasyCFGERRText dc.b "Error found in NewDefaultTool configurationfile.",10
dc.b "Refer to the manual.",0
even
EasyMEMERRText dc.b "Insufficient memory SORRY!.",0
even
EasyAPPERRText dc.b "Can't find AppIcon on requested path",0
even
EasyOpenCFGERRText dc.b "Can't find configurationfile",10
dc.b "Refer to the manual.",0
even
EasyABORT dc.b "ABORT",0
even
EASYStruct2 dc.l 20 ;Len of structure
dc.l 0
dc.l Txt1
EASYText2 dc.l EasyTextstr
dc.l EasyHIDEQUIT
EndEasyStruct2 dc.l 0
EasyHIDEQUIT dc.b "HIDE|QUIT",0
even
EasyTextstr dc.b 'NewDefaultTool © Copyright 1992',10
dc.b 'by Kjell Cederfeldt',10,10
dc.b 'This program is in the Public Domain.',10
dc.b 'It may be freely distributed for',10
dc.b 'non-commercial purposes only.',0
EndEasyTextSrt even
NewMessage: dc.l 0
DosBase: dc.l 0
IconBase: dc.l 0
AslBase: dc.l 0
IntBase: dc.l 0
FileReq: dc.l 0
disklib_base: dc.l 0
WBBase: dc.l 0
CLIpoint: dc.l 0
FileMem: dc.l 0
FileInfoMem: dc.l 0
ConfigMem: dc.l 0
MyPort: dc.l 0
AppDiskOBJ: dc.l 0
AppIconHandle: dc.l 0
sigbit: dc.l 0
MysigBit: dc.l 0
FoundPort dc.l 0
AppMsgStruct dc.l 0
FileArpMem: dc.l 0
EntryMem: dc.l 0
Diskobj: dc.l 0
FileLen: dc.l 0
MyFileLock: dc.l 0
OldLock: dc.l 0
CfgFile: dc.l 0
NewDefTool: dc.l 0
CopyDefTool: dc.l 0
StartOFUIface: dc.l 0
EndOFUIface: dc.l 0
StartOFTools: dc.l 0
EndOFTools: dc.l 0
StartOFFiles: dc.l 0
EndOFFiles: dc.l 0
APPICONX: dc.l 0 ;X-position for AppIcon
APPICONY: dc.l 0 ;Y-position for AppIcon
DirEntryType: dc.l 0 ;> 0 = Directory, < 0 = File.
RetCode1 dc.l 0 ;avgör om ett anrop lyckats/misslyckats.
MatchOK: dc.w 0 ;0= no match of string found, 1= match string found
CLIMORE: dc.w 0 ;0= no more names from cli's arglist 1= there are more
AskTrue: dc.w 0 ;0= no ask-requester, 1= ask-requester
APPICONTRUE: dc.w 0 ;0= no AppIcon, 1= AppIcon
pri: dc.b 0
even
VersionTag dc.b 0,'$VER: NewDefaultTool V1.01 (92-01-01)'
dc.b ' © Copyright by Kjell Cederfeldt 1992',10,0
even
Feed: dc.b 10
even
end
*********************************************************************************
***** ********************************************
***** COMMENTS / FREE TEXTFORM ********************************************
***** ********************************************
*********************************************************************************
I denna version:
* Till så att det går att skriva enbart ? för hjälptext (men -? -h fungerar också)
* Ny testutskrifts Found tool... xxxxxxxxx Change tool.... xxxxxxxxxx har lagts
till och ser bra ut.
* 0.32-0.33 Klart uppbettrad cli-hantering. Bort med #? el. * för att hitta
currentdir. för att byta alla i currentdir skrivs ""
* Förbättrad feltexthantering i CLI!
* Byte via filnamna (FILENAME:) är äntligen klart och fungerar, dock verkar det
problem via CLI (men den biten skall ju få ett rejält lyft nu innan den släpps)
FILNAME: har högsta prioriteten, därefter (om inte match) tools:
* 0.30 update! Bugg fixad, En reply glömdes bort vid AppUserWin så dubbelklicken,
besvardes aldrig.
* 0.30 Fixat så att [TAB] godkännes i konfigurationsfilen. Error-requester om
konfigurationsfilen inte hittas, samt om inte AppIconen hittas.
Det kommer inte upp någon Appicon om man kör från CLI (även om man anger detta)
(Möjligen skall NDT känna av om det finns en Workbench screen = OpenPubScreen()
och om det finns lägga ut en Appicon om detta är konfigurerat, annars ASL'req.
* 0.29 Bytte ut "fönstret" mot EasyRequester istället, samt lagt till en del error-
requesters
* X & Y position fixades i 0.27
* Ändrat så att programmet inte avslutar då man släpper en AppIcon eller en icon
som intr har en fil. (Se direkt efter CheckFileDir i HandlesFile)
* Tagit bort en allvarlig bugg i AllocMoreEntrys rutinen (plats för fler filnamn om
de 512 inte skulle räcka) i AllocmoreEntrys görs en ny CheckFileDir (den bör inte
misslyckas) det finns ingen bra koll på rutinen misslyckas.
* Bytit ut arp's wildcardsrutiner mot Commodores. (* ej längre godkänd som wildcard)
* Blikar till (DisplayBeep) varje gång programmet får ett meddelande då fönstret är
öppet.
* Tar emot meddelanden även då föstret är öppet (från AppIcone och andra Tasks)
* Föster som öppnads när man klickar på Appiconen.
* Tillägg av nytt keyword i config-filen (APPICON) en AppIcon öppnas om detta är
valt dock kan inget ifrån den hanteras ännu. Namnet till iconen sparas men
används inte heller ännu.
* ARP & REQ filerequester är borttagna helt!
* Helt ny wildcard rutin för Old/New defaultTool. Nu används arp's rutiner för att
avgöra om strängarna matchar varandra. Allt ser ut att fungera bra.
* Det fungerar att ange path och filnamn från CLI. Vill man byta alla i CurrentDir
så går det att skriva * el. #? men det går inte att använda WildCard i överigt.
* Sökning i flera rader fungerar bra.
Dock borde inte fler radsrutinen ställa till med problem, när de andra wildcard
rutinerna blir klara. (fungerar bra även för den utan wildcards)
FIXA:
* Bör kolla att newdeftool och olddeftool inte är samma så den byts i onödan (även
om olddeftool uppfyller enligt konfigfilen ex: *more i konfigfilen, står Sys:
Utilities/More i iconen och destsidan i konfigfilen. Enklet att fixa ?
---> Kommentar till ovan. Detta borde gå att lösa med WildCardrutinerna.
Dessutom bör det gå ifall man vill byta till "RÄTT" Case i iconen.
* Om det är mellan rum i filnamnet till Appcion i configfilen bör detta kunna
hanteras med fnuttar. Knulla är skönt!
* Om det är mellanrum i strängen så måste min match-rutin klara fnuttar och namnet.
* Om man skiver filnamnet från CLI med olika Case mot vad filen har så råkar den
sparas med det Case som skrivs från CLI
* Om det är mellanrum i filnamet så klara inte argumet-rutine för CLI det.
* Det vore bra om filnamnsrutinen kunde klara Wildcards också.
** Tag bort utskrift av tooltypes (eller fixa till bättre) i GetDefTool funktionen.
IDEER:
* Man skall kunna lägga till ASK sist (först??) på raden i config-file för att
en requester skall komma upp och fråga om strängen AAAA skall bytas mot BBBB
(YES = utför det bytet, NO utför inte, ALL utför byte på alla projekt.iconer.
* Kanske man kan vilja lägga till standard tool-type rader vid byte av default-
tool? se nedan:
APPICON: = ram:TFD-T
TOOLS:
*MutchMore Sys:Utilities/More
#?DPaint Work:Nytto/Grafik/DPaint/DPaint
#?:ced Sys:Utilities/ED
FILENAME:
ReadMe#? Sys:Utilities/More
Read.Me#? Sys:Utilities/More
#?.s Sys:Utilities/Ed
TOOLTYPE:
1COLOR=4
2COLOR=8
3SCREEN=CUSTOM
4SCREEN=WORKBECH
5INTERLACE=YES
6INTERLACE=NO
**********************************************************************************